<!DOCTYPE html> 
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
    <title>{{ coun_name }}余额（企）</title>
    <link rel="stylesheet" href="/static/bower_components/weui/dist/style/weui.min.css"/>
    <link rel="stylesheet" href="/static/css/example.css?v=0.1.4"/>
  </head>
  <body>
    <div>
        <div>
            <!-- {{sig['result']['signature']}}
            timestamp: {{sig['result']['timestamp']}},
            nonceStr: {{sig['result']['nonceStr']}},
            signature: {{sig['result']['signature']}},
            appId: {{CorpId}} -->
            <div id="userid"  style ="display:none">{{ UserId }}</div>
            <a id="scanQRCode" href="javascript:;" class="weui-btn weui-btn_mini weui-btn_warn">扫描二维码</a>

        </div>
    </div>
    <script src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
    <script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script type="text/javascript">
        wx.config({
            debug: true,
            appId: 'ww3160ba6adb403b67',
            timestamp: '{{ sig.result.timestamp }}',
            nonceStr: '{{ sig.result.nonceStr }}',
            signature: '{{ sig.result.signature }}',
            jsApiList: [ 'checkJsApi', 'scanQRCode' ]
        });//end_config
    
        wx.error(function(res) {
            alert("出错了：" + res.errMsg);
        });

        wx.ready(function() {
            wx.checkJsApi({
                jsApiList : ['scanQRCode'],
                success : function(res) {
                }
            });
    
            //扫描二维码
            document.querySelector('#scanQRCode').onclick = function() {
                wx.scanQRCode({
                    desc: 'scanQRCode desc',
                    needResult : 1, // 默认为0，扫描结果由微信处理，1则直接返回扫描结果，
                    scanType : [ "qrCode", "barCode" ], // 可以指定扫二维码还是一维码，默认二者都有
                    success : function(res) {
                        var result = res.resultStr; // 当needResult 为 1 时，扫码返回的结果
                        var userid = $("#userid").html();
                        window.location.href = "/login?userid="+userid+"&dwid="+result;
                    }
                });
            };//end_document_scanQRCode
            
        });//end_ready


    </script>
  </body>
</html>